Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue build] with webpack.config.js, Component css lost in index.css #599

Closed
strongdevx opened this issue Sep 27, 2017 · 0 comments
Closed

Comments

@strongdevx
Copy link

strongdevx commented Sep 27, 2017

my component like this:

<template>
...
</template>
<script>
//some code here
</script>
<style>
 .content{
  width:500px;
  height:600px;
}
</style>

I want to use vue build create umd bundle.

when I use vue build,the result file index.css include the style content. like this:

vue build my-component.vue --prod --lib

But when I use vue build with webpack.config.js,the style(css) lost. like this:

vue build my-component.vue --prod --lib --webpack webpack.config.js

My webpack.config.js:

var path = require('path');
var utils = require('./utils');
var webpack = require('webpack');
var merge = require('webpack-merge');
var webpackBaseConfig = require('./webpack.base.conf.js');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

process.env.NODE_ENV = 'production';

module.exports = merge(webpackBaseConfig, {
  entry: './index.js',
  output: {
    path: path.resolve(__dirname, '../dist'),
    publicPath: '/dist/',
    filename: 'index.js',
    library: 'leaflet-map',
    libraryTarget: 'umd',
    umdNamedDefine: true
  },
  externals: {
    vue: {
      root: 'Vue',
      commonjs: 'vue',
      commonjs2: 'vue',
      amd: 'vue'
    }
  },
  plugins: [
    // @todo
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': '"production"'
    }),
    new ExtractTextPlugin({
      filename: utils.assetsPath('css/[name].[contenthash].css')
    })
  ]
});

Is something missing from me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant