Skip to content

Commit

Permalink
chore: fix build bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vulcangz committed Feb 23, 2021
1 parent 5b1a190 commit 2a65f67
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 104 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test": "start-server-and-test dev http://localhost:5000 cy:run"
},
"svelte": "src/components/components.module.js",
"version": "0.1.0",
"version": "0.1.1",
"devDependencies": {
"@babel/core": "7.11.5",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
Expand Down Expand Up @@ -76,5 +76,6 @@
"bugs": {
"url": "https://github.com/vulcangz/svelte-baidumaps/issues"
},
"homepage": "https://github.com/vulcangz/svelte-baidumaps#readme"
"homepage": "https://github.com/vulcangz/svelte-baidumaps#readme",
"dependencies": {}
}
196 changes: 98 additions & 98 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,111 +1,111 @@
import { terser } from 'rollup-plugin-terser';
import autoPreprocess from 'svelte-preprocess';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import pkg from './package.json';
import resolve from 'rollup-plugin-node-resolve';
import svelte from 'rollup-plugin-svelte';
import { terser } from 'rollup-plugin-terser'
import autoPreprocess from 'svelte-preprocess'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import livereload from 'rollup-plugin-livereload'
import pkg from './package.json'
import resolve from 'rollup-plugin-node-resolve'
import svelte from 'rollup-plugin-svelte'

const production = !process.env.ROLLUP_WATCH;
const production = !process.env.ROLLUP_WATCH
const name = pkg.name
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, (m) => m.toUpperCase())
.replace(/-\w/g, (m) => m[1].toUpperCase());
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, (m) => m.toUpperCase())
.replace(/-\w/g, (m) => m[1].toUpperCase())

export default {
input: !production ? 'src/main.js' : 'src/components/components.module.js',
output: !production
? {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/bundle.js',
}
: [
{
file: pkg.module,
format: 'es',
sourcemap: true,
name,
},
{
file: pkg.main,
format: 'umd',
sourcemap: true,
name,
},
],
plugins: [
babel({
runtimeHelpers: true,
}),
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: (css) => {
css.write('bundle.css');
},
input: !production ? 'src/main.js' : 'src/components/components.module.js',
output: !production
? {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/bundle.js'
}
: [
{
file: pkg.module,
format: 'es',
sourcemap: true,
name
},
{
file: pkg.main,
format: 'umd',
sourcemap: true,
name
}
],
plugins: [
babel({
runtimeHelpers: true
}),
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: (css) => {
css.write('bundle.css')
},

/**
* Auto preprocess supported languages with
* '<template>'/'external src files' support
**/
preprocess: autoPreprocess({
postcss: true,
scss: { includePaths: ['src', 'node_modules'] },
}),
}),
/**
* Auto preprocess supported languages with
* '<template>'/'external src files' support
**/
preprocess: autoPreprocess({
postcss: true,
scss: { includePaths: ['src', 'node_modules'] }
})
}),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve({
browser: true,
dedupe: ['svelte'],
}),
commonjs({
include: ['node_modules/**'],
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs({
include: ['node_modules/**']
}),

// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),

// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),

// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
],
watch: {
clearScreen: false,
},
};
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
}

function serve() {
let started = false;
function serve () {
let started = false

return {
writeBundle() {
if (!started) {
started = true;
return {
writeBundle () {
if (!started) {
started = true

require('child_process').spawn(
'npm',
['run', 'start', '--', '--dev'],
{
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
}
);
}
},
};
require('child_process').spawn(
'npm',
['run', 'start', '--', '--dev'],
{
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
}
)
}
}
}
}

0 comments on commit 2a65f67

Please sign in to comment.